/*
 * Project Name: xdtech-core
 * File Name: ModelTabel.java
 * Copyright: Copyright(C) 1985-2015 ZKTeco Inc. All rights reserved.
 */
package com.xdtech.coder.vo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;

import com.xdtech.coder.model.ModelTable;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.web.freemark.item.GridColumn;

/**
 * TODO 一句话功能简述，请确保和下面的block tags之间保留一行空行
 * <p>
 * TODO 功能详细描述，若不需要请连同上面的p标签一起删除
 * 
 * @author <a href="max.zheng@zkteco.com">郑志雄</>
 * @version TODO 添加版本
 * @see 相关类或方法，不需要请删除此行
 * @since 2015-1-24 上午10:54:15
 */
public class ModelTableItem 
{
	private Long id;
	@GridColumn(title="表名",width=120)
	private String tableName;
	@GridColumn(title="模块名称")
	private String moduleName;
	@GridColumn(title="模型名称")
	private String modelName;
	@GridColumn(title="说明",width=150)
	private String comment;
	
	private List<ModelTableMappedItem> mappedItems = new ArrayList<ModelTableMappedItem>();
	
	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public String getTableName()
	{
		return tableName;
	}

	public void setTableName(String tableName)
	{
		this.tableName = tableName;
	}

	public String getModuleName()
	{
		return moduleName;
	}

	public void setModuleName(String moduleName)
	{
		this.moduleName = moduleName;
	}

	public String getModelName()
	{
		return modelName;
	}

	public void setModelName(String modelName)
	{
		this.modelName = modelName;
	}

	public String getComment()
	{
		return comment;
	}

	public void setComment(String comment)
	{
		this.comment = comment;
	}

	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static ModelTableItem createItem(ModelTable modelTable) {
		ModelTableItem modelTableItem = new ModelTableItem();
		BeanUtils.copyProperties(modelTableItem, modelTable);
		return modelTableItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<ModelTableItem> createItems(List<ModelTable> modelTables) {
		List<ModelTableItem> modelTableItems = new ArrayList<ModelTableItem>();
		for (ModelTable modelTable : modelTables) {
			modelTableItems.add(createItem(modelTable));
		}
		return modelTableItems;
	}

	public List<ModelTableMappedItem> getMappedItems() {
		return mappedItems;
	}

	public void setMappedItems(List<ModelTableMappedItem> mappedItems) {
		this.mappedItems = mappedItems;
	}
}
